﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Web.Routing;
using Axis.Web.Administrator.Global;
using Axis.BusinessObject.Core;
using FWS.Framework.Log;

namespace Axis.Web
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            RegisterRoute(RouteTable.Routes);
        }

        protected void Session_Start(object sender, EventArgs e)
        {
            /*  var member = new CMemberList();
              Session["MEMBERINFO"] = member;
             * */
        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }
        protected void Application_EndRequest(object sender, EventArgs e)
        {

        }
        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {
            //var ctx = HttpContext.Current;
            //var ex = ctx.Server.GetLastError();
            //if(ex.ToString()=="File does not exist.")
            //    ctx.Response.Clear();
            //ctx.Response.ClearHeaders();
            //Server.Transfer("~/ApplicationException.html");

        }

        protected void Session_End(object sender, EventArgs e)
        {
            CLogManager.WritePL("Session_End", e.ToString() + ":" + DateTime.Now.ToString());
        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
        public static void RegisterRoute(RouteCollection routes)
        {
            RouteTable.Routes.Add("NewsDetail", new Route("Views/News/{ID}", new CRoutePageHandler("~/Views/News/NewsDetail.aspx")));
            RouteTable.Routes.Add("NewsDetail2", new Route("Views/News/{ID}/{T}", new CRoutePageHandler("~/Views/News/NewsDetail.aspx")));
            RouteTable.Routes.Add("SKDV", new Route("Views/SKDV/{ID}", new CRoutePageHandler("~/Views/SKDV/SKDV.aspx")));
            RouteTable.Routes.Add("YKienTieuDung", new Route("Views/YKienTieuDung/{ID}", new CRoutePageHandler("~/Views/YKienTieuDung/Default.aspx")));
            RouteTable.Routes.Add("CPTT", new Route("Views/CafeThiTruong/{ID}", new CRoutePageHandler("~/Views/CafeThiTruong/Default.aspx")));
            RouteTable.Routes.Add("TinTucKhuyenMai", new Route("Views/TinTucKhuyenMai/{ID}", new CRoutePageHandler("~/Views/TinTucKhuyenMai/Default.aspx")));
            RouteTable.Routes.Add("TagCloud", new Route("Views/TagCloud/{ID}", new CRoutePageHandler("~/Views/TagCloud/CloundTagDetail.aspx")));
            RouteTable.Routes.Add("Project", new Route("Views/Project/{ProjectID}", new CRoutePageHandler("~/Views/Project/Project.aspx")));
            RouteTable.Routes.Add("Project2", new Route("Views/Project/{ProjectID}/{T}", new CRoutePageHandler("~/Views/Project/Project.aspx")));
            RouteTable.Routes.Add("Research", new Route("Views/Research/{ID}", new CRoutePageHandler("~/Views/Research/ResearchList.aspx")));
            RouteTable.Routes.Add("Research2", new Route("Views/Research/{ID}/{T}", new CRoutePageHandler("~/Views/Research/ResearchList.aspx")));

        }
    }
}